/*
 * Copyright (c) 2020. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.evenmo.string;

import org.junit.Test;

import java.util.Comparator;
import java.util.Set;
import java.util.TreeSet;

/**
 * This is Description
 *
 * @author moyongjun
 * @date 2020/01/18
 */
public class TestStudent {
    @Test
    public void Test(){
        System.out.println("sdf");
    }

    @Test
    public void testStudent(){

        Set<Student> treeSet=treeSet=new TreeSet<Student>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int i=o1.getId()-o2.getId();

                int j=i==0?o1.getName().compareTo(o2.getName()):i;

                return j;
            }
        });


        treeSet.add(new Student(1, "abc", 1, true));
        treeSet.add(new Student(2, "abcd", 1, true));
        treeSet.add(new Student(3, "abce", 1, true));
        treeSet.add(new Student(1, "abc", 1, true));
        treeSet.add(new Student(4, "abe", 1, true));
        treeSet.add(new Student(1, "abea", 1, true));

        for (Student student : treeSet) {
            System.out.println(student);
        }

    }
}
